package com.cecsmsserve.controller;


import com.cecsmsserve.entity.ServiceOrder;
import com.cecsmsserve.service.IServiceOrderService;
import com.cecsmsserve.util.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-17
 */
@CrossOrigin
@RestController
@RequestMapping("/serviceOrder")
public class ServiceOrderController {

    @Autowired
    IServiceOrderService service;

    @GetMapping("/selectAll")
    public CommonResult selectAll(){return service.selectAll();}

    @GetMapping("/selectAllByPage/{current}/{size}")
    public CommonResult selectAllByPage(@PathVariable("current")int current,@PathVariable("size")int size){
        return service.selectAllByPage(current,size);
    }

    //医疗订单
    @GetMapping("/selectServiceByPage/{current}/{size}")
    public CommonResult selectServiceByPage(@PathVariable("current")int current,@PathVariable("size")int size){
        return service.selectServiceByPage(current,size);
    }

    //医疗订单
    @GetMapping("/selectHealthByPage/{current}/{size}")
    public CommonResult selectHealthByPage(@PathVariable("current")int current,@PathVariable("size")int size){
        return service.selectHealthByPage(current,size);
    }

    @GetMapping("/selectByUId/{uId}")
    public CommonResult selectByUId(@PathVariable("uId")int uId){
        return service.selectByUId(uId);
    }

    @GetMapping("/selectByuIdByState/{uId}/{state}")
    public CommonResult selectByuIdByState(@PathVariable int uId,@PathVariable int state){
        return service.selectByuIdByState(uId,state);
    }

    @GetMapping("/selectByState/{state}")
    public CommonResult selectByState(@PathVariable("state")int state){
        return service.selectByState(state);
    }

    @PutMapping("/insert")
    public CommonResult insert(@RequestBody ServiceOrder serviceOrder){
        return service.insert(serviceOrder);
    }

    @PostMapping("/update")
    public CommonResult update(@RequestBody ServiceOrder serviceOrder){
        return service.update(serviceOrder);
    }

}
